package com.wgts.wgts.mvp.view.activity.awardmore;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wgts.wgts.R;
import com.wgts.wgts.control.recycleview.BaseLoadMoreAdapter;
import com.wgts.wgts.mvp.view.activity.guessing.GuessingOrderChildAdapter;
import com.wgts.wgts.netmodle.resp.GuessingAndAwardOrderEntity;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/*
 *
 *
 *   data:2018/10/1221:14
 *
 *   订单父recycleView Adapter
 *
 */public class MyAwardOrderParentAdapter extends BaseLoadMoreAdapter<MyAwardOrderParentAdapter.ViewHold> {
    private Context context;
    private List<GuessingAndAwardOrderEntity> list;
    private AwardOrderChildAdapter childAdapter;
    //0 ， 1
    private int type;

    //0  1， 我参与的 2
    private int joinType;

    public MyAwardOrderParentAdapter(Context context, List<GuessingAndAwardOrderEntity> list, int type, int joinType) {
        super(context);
        this.context = context;
        this.list = list;
        this.type = type;
        this.joinType = joinType;
    }

    @NonNull
    @Override
    public ViewHold onCreateBodyViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new ViewHold(LayoutInflater.from(context).inflate(R.layout.guessing_awrad_parent_recycle_item, viewGroup, false));
    }

    @Override
    public void onBindBodyViewHolder(@NonNull ViewHold viewHold, int i) {
        LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
        viewHold.guessingAwardParentRecycle.setLayoutManager(linearLayoutManager);
        childAdapter = new AwardOrderChildAdapter(context, list.get(i).list, type, joinType);
        viewHold.guessingAwardParentRecycle.setAdapter(childAdapter);
    }

    @Override
    public int getBodyItemCount() {
        return list.size();
    }

    @Override
    public int getBodyItemViewType(int position) {
        return 0;
    }


    public class ViewHold extends RecyclerView.ViewHolder {
        @BindView(R.id.guessing_award_parent_recycle)
        RecyclerView guessingAwardParentRecycle;
        public ViewHold(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
